<div id="sidebar2" class="sidebar">
	<ul>
		<li>
			<!--- default the incoming search string --->
			<cfparam name="s" type="string" default="" />
			<cfoutput>
				<form id="searchform" method="get" action="search.cfm">
					<div>
						<h2>Game Search</h2>
						<input type="text" name="s" id="s" size="15" value="#s#" />
					</div>
				</form>
			</cfoutput>
		</li>
		<li>
        	<cfif (not structKeyExists(application, 'stGOTD') or (dateDiff('d', application.stGOTD.lastUpdated, now()) gte 1))>
				<!--- Setup the values for the GOTD. First get a count of the games in the system. --->
                <cfquery name="qGameCount" datasource="sixdegreesimprov">
                    SELECT COUNT(game_id) AS total
                    FROM igdb_games
                </cfquery>
                <cfset startRangeID = 1 />
                <cfset endRangeID = qGameCount.total />
                <!--- Call Randomize to seed the random number generator, then get the random ID. --->
                <cfset r = randomize(second(now()), "SHA1PRNG")>
                <cfset gotd_id = randRange(startRangeID, endRangeID, "SHA1PRNG") />
                <!--- store in application scope --->
                <cfset application.stGOTD = structNew() />
                <cfset application.stGOTD.lastUpdated = now() />
                <!--- Go get the random game --->
                <cfquery name="application.stGOTD.qGOTD" datasource="sixdegreesimprov">
                    SELECT game_id, game_name, descrip
                    FROM igdb_games
                    WHERE (game_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#gotd_id#" />)
                </cfquery>
			</cfif>
			<h2>Game of the Day</h2>
            <cfoutput>
				<p class="tag"><a href="gameInfo.cfm?game_id=#application.stGOTD.qGOTD.game_id#">#application.stGOTD.qGOTD.game_name#</a></p>
            </cfoutput>
		</li>
		<li>
			<h2>Game Categories</h2>
			<ul>
				<!--- Get all the game categories so we can list them down the right side --->
				<cfquery name="qCats" datasource="sixdegreesimprov" cachedwithin="#createTimeSpan(0, 1, 0, 0)#">
					SELECT category_id, category_name
					FROM igdb_categories
					ORDER BY category_name
				</cfquery>
                <!--- output those categories --->
				<cfoutput query="qCats">
					<li><a href="category.cfm?category_id=#category_id#">#category_name#</a></li>
				</cfoutput>
			</ul>
		</li>
	</ul>
</div>